import org.apache.spark.{SparkConf, SparkContext}

object TopValues {

  def main(args: Array[String]): Unit = {
    var num:Int = 0;
    val conf =new SparkConf().setAppName("TopValues").setMaster("local")
    conf.set("spark.testing.memory", "2147480000")
    val sc = new SparkContext(conf)
    val lines = sc.textFile("src/topvalues", 2)
    lines.filter(line => (line.trim().length>0)&&(line.split(",").length == 4))
      .map(line => line.split(",")(2))
      .map(x => (x.toInt,""))
      .sortByKey(false)
      .take(5)
      .foreach(x=>{
        num = num+1
        println(num+"\t"+x._1)
      })
  }

}
